<%@page import="com.yunhuakeji.wddx.utils.IsNull"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.json.JSONArray"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
JSONArray arr;
try{
   // arr = JSONArray.fromObject(request.getAttribute("result"));
    arr = JSONArray.fromObject(JSONObject.fromObject(JSONObject.fromObject(JSONArray.fromObject(request.getAttribute("result")).get(0)).get("content")).get("message"));
}catch(Exception e){
    arr = null;
}  
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>职业测评</title>
     <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0">
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="css/myreport.css">
	<script src="js/jquery.min.js"></script>
	<script src="js/myReport.js"></script>
	<script src="js/layer.js"></script>
  </head>
  <style>
  	
  </style>
  <body>
    <%if(arr.size()>0){ %>
  	<!-- home -->
  	<div class="report-header">
  			<a>职业测评</a>
  	</div>
  	<div class="report-menu">
  	    <%for(int i=0;i<arr.size();i++){ 
  	      JSONObject obj = arr.getJSONObject(i);
  	    %>
  		<div class="mb15 question">
  			<a class="mt10 mb10"><%=i+1%>.<%=obj.getString("title") %></a>
  			<div class="careerQuiz-content pb0 mt10">
	  			<ul>
	  			<%JSONArray radio = obj.getJSONArray("radio");
	  			for(int j=0;j<radio.size();j++){ %>
	  				<li>
	  					<div class="careerQuiz-check-box">
		  					<span></span>
		  					<span></span>
	  					</div>
	  					<a value="<%=radio.getJSONObject(j).getString("text")%>"><%=radio.getJSONObject(j).getString("value") %></a>
	  					<div class="clear"></div>
	  				</li>
	  			<%} %>
	  			</ul>
	  		</div>
  		</div>
  	<%} %>
	  	<div class="report-footer">
	  	    <form name="userid_form" type="post" action="professionalAssessment/getPostListWithApp.action?">
	  	         <input type="hidden" name="bfb"/>
	  	         <input type="hidden" name="post"/>
	  	         <input type="hidden" name="userid"/>
	  	         <input type="hidden" name="ticket"/>
	  	    </form>
	  		<a><b>提交测评结果</b></a>
	  	</div>
  	</div>
  	<%} %>
  	<script>
  	<%-- +'<%=session.getAttribute("userid")%>'+"&ticket="+'<%=session.getAttribute("ticket")%>' --%>
  	var user_id = '<%=request.getParameter("userid")%>';
	var ticket = '<%=request.getParameter("ticket")%>';
  	
  	$('.careerQuiz-check-box').click(function(){
  		$(this).parent().siblings().children().children("span").removeClass("active");
  		$(this).children("span:last-child").toggleClass("active");
  	});
  	
  	$('.report-footer a').click(function(){
  	 if($('div.question').length==$('span.active').length){
  				  var P=0,J=0,E=0,I=0,S=0,N=0,T=0,F=0;
  				  $('span.active').parent().next().each(function(){
  				     var _value = $(this).attr('value');
  					 if(_value){
  						 switch(_value){
  						     case 'P':
  						          P++
  						          break;
  						     case 'J':
  						          J++
  						          break;
  						     case 'E':
  						          E++
  						          break;
  						     case 'I':
  						          I++
  						          break;
  						     case 'S':
  						          S++
  						          break;
  						     case 'N':
  						          N++
  						          break;
  						     case 'T':
  						          T++
  						          break;
  						     case 'F':
  						          F++
  						          break;
  						  }
  					  }
  				    });
  				  var conclusion= (I>=E ? 'I':'E')+( N>=S ? 'N':'S')+( F>=T ? 'F':'T')+(P >=J ? 'P':'J') ;
 				  var obj = {};
 				  obj.E = E;obj.I = I;obj.S = S;obj.N = N;obj.T = T;obj.F = F;obj.J = J;obj.P = P;
 				  $('form[name="userid_form"] input[name=post]').attr('value',conclusion);  
 				  $('form[name="userid_form"] input[name=bfb]').attr('value',JSON.stringify(obj));
 				  $('form[name="userid_form"] input[name=userid]').attr('value',user_id);
 				  $('form[name="userid_form"] input[name=ticket]').attr('value',ticket);
 				  $('form[name="userid_form"]').submit();
  				  }
  	    		 else
  	    			alert("作答后查看测试结果");
  	 
  	      });
  	</script>
  </body>
</html>
